home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectPlay / VoiceGroup / frmVoice.frm < prev    next >
Text File  |  2001-10-08  |  21KB  |  562 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmVoice 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "DirectPlay Voice Sample"
  6.    ClientHeight    =   3285
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   5985
  10.    Icon            =   "frmVoice.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   3285
  15.    ScaleWidth      =   5985
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin VB.CommandButton cmdClient 
  18.       Caption         =   "Settings"
  19.       Default         =   -1  'True
  20.       Height          =   375
  21.       Left            =   4680
  22.       TabIndex        =   7
  23.       Top             =   300
  24.       Width           =   1215
  25.    End
  26.    Begin VB.CommandButton cmdCancel 
  27.       Cancel          =   -1  'True
  28.       Caption         =   "Exit"
  29.       Height          =   375
  30.       Left            =   4680
  31.       TabIndex        =   6
  32.       Top             =   780
  33.       Width           =   1215
  34.    End
  35.    Begin VB.ComboBox cboTalkingGroup 
  36.       Height          =   315
  37.       ItemData        =   "frmVoice.frx":0442
  38.       Left            =   1980
  39.       List            =   "frmVoice.frx":0458
  40.       Style           =   2  'Dropdown List
  41.       TabIndex        =   5
  42.       Top             =   2880
  43.       Width           =   2595
  44.    End
  45.    Begin VB.ComboBox cboMyGroup 
  46.       Height          =   315
  47.       ItemData        =   "frmVoice.frx":0498
  48.       Left            =   1980
  49.       List            =   "frmVoice.frx":04AE
  50.       Style           =   2  'Dropdown List
  51.       TabIndex        =   3
  52.       Top             =   2520
  53.       Width           =   2595
  54.    End
  55.    Begin MSComctlLib.ListView lvMembers 
  56.       Height          =   2175
  57.       Left            =   60
  58.       TabIndex        =   1
  59.       Top             =   300
  60.       Width           =   4515
  61.       _ExtentX        =   7964
  62.       _ExtentY        =   3836
  63.       View            =   3
  64.       LabelEdit       =   1
  65.       LabelWrap       =   -1  'True
  66.       HideSelection   =   -1  'True
  67.       _Version        =   393217
  68.       ForeColor       =   -2147483640
  69.       BackColor       =   -2147483643
  70.       BorderStyle     =   1
  71.       Appearance      =   1
  72.       NumItems        =   4
  73.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  74.          Text            =   "Name"
  75.          Object.Width           =   2540
  76.       EndProperty
  77.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  78.          SubItemIndex    =   1
  79.          Text            =   "Status"
  80.          Object.Width           =   1235
  81.       EndProperty
  82.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  83.          SubItemIndex    =   2
  84.          Text            =   "Group"
  85.          Object.Width           =   2117
  86.       EndProperty
  87.       BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  88.          SubItemIndex    =   3
  89.          Text            =   "Target"
  90.          Object.Width           =   1764
  91.       EndProperty
  92.    End
  93.    Begin VB.Label lblInfo 
  94.       BackStyle       =   0  'Transparent
  95.       Caption         =   "I'm talking to this group:"
  96.       Height          =   255
  97.       Index           =   2
  98.       Left            =   60
  99.       TabIndex        =   4
  100.       Top             =   2940
  101.       Width           =   1815
  102.    End
  103.    Begin VB.Label lblInfo 
  104.       BackStyle       =   0  'Transparent
  105.       Caption         =   "I'm currently in the group:"
  106.       Height          =   255
  107.       Index           =   1
  108.       Left            =   60
  109.       TabIndex        =   2
  110.       Top             =   2580
  111.       Width           =   1815
  112.    End
  113.    Begin VB.Label lblInfo 
  114.       BackStyle       =   0  'Transparent
  115.       Caption         =   "Members of this conversation:"
  116.       Height          =   255
  117.       Index           =   0
  118.       Left            =   120
  119.       TabIndex        =   0
  120.       Top             =   60
  121.       Width           =   3855
  122.    End
  123. End
  124. Attribute VB_Name = "frmVoice"
  125. Attribute VB_GlobalNameSpace = False
  126. Attribute VB_Creatable = False
  127. Attribute VB_PredeclaredId = True
  128. Attribute VB_Exposed = False
  129. Option Explicit
  130. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  131. '
  132. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  133. '
  134. '  File:       frmVoice.frm
  135. '
  136. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  137. Implements DirectPlayVoiceEvent8
  138. Implements DirectPlay8Event
  139.  
  140. Private Sub UpdateList(ByVal lPlayerID As Long, fTalking As Boolean)
  141.     Dim lCount As Long
  142.     For lCount = lvMembers.ListItems.Count To 1 Step -1
  143.         If lvMembers.ListItems.Item(lCount).Key = "K" & CStr(lPlayerID) Then
  144.             'Change this guys status
  145.             If fTalking Then
  146.                 lvMembers.ListItems.Item(lCount).SubItems(1) = "Talking"
  147.             Else
  148.                 lvMembers.ListItems.Item(lCount).SubItems(1) = "Silent"
  149.             End If
  150.         End If
  151.     Next
  152. End Sub
  153.  
  154. Private Sub cboMyGroup_Click()
  155.     On Error Resume Next
  156.     Dim lMsg As Long, lOffset As Long
  157.     Dim oBuf() As Byte
  158.     
  159.     'Ok, I don't want to be in this group anymore.. let's change..
  160.     UpdateGroup glMyPlayerID, cboMyGroup.ListIndex
  161.     'Now send a message to everyone telling them
  162.     If DPlayEventsForm.IsHost Then
  163.         If cboMyGroup.ListIndex = 0 Then
  164.             RemovePlayerFromAllGroups glMyPlayerID
  165.         Else
  166.             RemovePlayerFromAllGroups glMyPlayerID
  167.             'Add myself to the new group
  168.             dpp.AddPlayerToGroup glGroupID(cboMyGroup.ListIndex), glMyPlayerID, 0
  169.         End If
  170.     Else
  171.         lMsg = MSG_SERVERCHANGEGROUP
  172.         lOffset = NewBuffer(oBuf)
  173.         AddDataToBuffer oBuf, lMsg, LenB(lMsg), lOffset
  174.         AddDataToBuffer oBuf, CLng(cboMyGroup.ListIndex), SIZE_LONG, lOffset
  175.         dpp.SendTo DPNID_ALL_PLAYERS_GROUP, oBuf, 0, DPNSEND_GUARANTEED Or DPNSEND_NOLOOPBACK
  176.     End If
  177.     
  178.     lMsg = MSG_CHANGEGROUP
  179.     lOffset = NewBuffer(oBuf)
  180.     AddDataToBuffer oBuf, lMsg, LenB(lMsg), lOffset
  181.     AddDataToBuffer oBuf, CLng(cboMyGroup.ListIndex), SIZE_LONG, lOffset
  182.     dpp.SendTo DPNID_ALL_PLAYERS_GROUP, oBuf, 0, DPNSEND_GUARANTEED Or DPNSEND_NOLOOPBACK
  183. End Sub
  184.  
  185. Private Sub cboTalkingGroup_Click()
  186.     Dim lMsg As Long, lOffset As Long
  187.     Dim oBuf() As Byte
  188.     Dim lTargets(0) As Long
  189.     
  190.     'Who do I want to talk to?
  191.     If cboTalkingGroup.ListIndex = 0 Then 'Talk to everyone
  192.         
  193.         lTargets(0) = DVID_ALLPLAYERS
  194.         dvClient.SetTransmitTargets lTargets, 0
  195.     Else
  196.         If DPlayEventsForm.IsHost Then
  197.             lTargets(0) = glGroupID(cboTalkingGroup.ListIndex)
  198.         Else
  199.             lTargets(0) = GetGroupID(cboTalkingGroup.ListIndex)
  200.         End If
  201.         dvClient.SetTransmitTargets lTargets, 0
  202.     End If
  203.     
  204.     UpdateTarget glMyPlayerID, cboTalkingGroup.ListIndex
  205.     'Now send a message to everyone telling them
  206.     lMsg = MSG_CHANGETALK
  207.     lOffset = NewBuffer(oBuf)
  208.     AddDataToBuffer oBuf, lMsg, LenB(lMsg), lOffset
  209.     AddDataToBuffer oBuf, CLng(cboTalkingGroup.ListIndex), SIZE_LONG, lOffset
  210.     dpp.SendTo DPNID_ALL_PLAYERS_GROUP, oBuf, 0, DPNSEND_GUARANTEED Or DPNSEND_NOLOOPBACK
  211.     
  212. End Sub
  213.  
  214. Private Sub cmdCancel_Click()
  215.     Unload Me
  216. End Sub
  217.  
  218. Private Sub cmdClient_Click()
  219.     'Show the settings screen, and re-adjust them
  220.     frmVoiceSettings.Show vbModal
  221.     dvClient.SetClientConfig oClient
  222. End Sub
  223.  
  224. Private Sub Form_Load()
  225.   
  226.     Dim dpGroupInfo As DPN_GROUP_INFO
  227.     Dim lCount As Long
  228.     
  229.     DPlayEventsForm.RegisterCallback Me
  230.     'First let's set up the DirectPlayVoice stuff since that's the point of this demo
  231.     If DPlayEventsForm.IsHost Then
  232.         'After we've created (and opened) the session and got the first player, let's start
  233.         'the DplayVoice server
  234.         
  235.         If (dvServer Is Nothing) Then Set dvServer = dx.DirectPlayVoiceServerCreate
  236.             
  237.         dvServer.Initialize dpp, 0
  238.         dvServer.StartSession oSession, 0
  239.     
  240.     End If
  241.     
  242.     'Now create a client as well (so we can both talk and listen)
  243.     Set dvClient = dx.DirectPlayVoiceClientCreate
  244.     'Now let's create a client event..
  245.     dvClient.StartClientNotification Me
  246.     dvClient.Initialize dpp, 0
  247.     oSound.hwndAppWindow = Me.hwnd
  248.     
  249.     On Error Resume Next
  250.     dvClient.Connect oSound, oClient, 0
  251.     If Err.Number = DVERR_RUN_SETUP Then    'The audio tests have not been run on this
  252.                                             'machine.  Run them now.
  253.         'we need to run setup first
  254.         Dim dvSetup As DirectPlayVoiceTest8
  255.         
  256.         Set dvSetup = dx.DirectPlayVoiceTestCreate
  257.         dvSetup.CheckAudioSetup vbNullString, vbNullString, Me.hwnd, 0 'Check the default devices since that's what we'll be using
  258.         If Err.Number = DVERR_COMMANDALREADYPENDING Then
  259.             MsgBox "Could not start DirectPlayVoice.  The Voice Networking wizard is already open.  This sample must exit.", vbOKOnly Or vbInformation, "No Voice"
  260.             Cleanup
  261.             Unload Me
  262.             End
  263.         End If
  264.         If Err.Number = DVERR_USERCANCEL Then
  265.             MsgBox "Could not start DirectPlayVoice.  The Voice Networking wizard has been cancelled.  This sample must exit.", vbOKOnly Or vbInformation, "No Voice"
  266.             Cleanup
  267.             Unload Me
  268.             End
  269.         End If
  270.         Set dvSetup = Nothing
  271.         dvClient.Connect oSound, oClient, 0
  272.     ElseIf Err.Number <> 0 And Err.Number <> DVERR_PENDING Then
  273.         MsgBox "Could not start DirectPlayVoice.  This sample must exit." & vbCrLf & "Error:" & CStr(Err.Number), vbOKOnly Or vbCritical, "Exiting"
  274.         Cleanup
  275.         Unload Me
  276.         End
  277.     End If
  278.     
  279.     'We need to create our 5 groups
  280.     For lCount = 1 To 5
  281.         With dpGroupInfo
  282.             .lInfoFlags = DPNINFO_NAME
  283.             .Name = "Group" & CStr(lCount)
  284.         End With
  285.         dpp.CreateGroup dpGroupInfo, 0
  286.     Next
  287.     
  288.     cboMyGroup.ListIndex = 0
  289.     cboTalkingGroup.ListIndex = 0
  290.     UpdatePlayerList
  291.     
  292.  
  293. End Sub
  294.  
  295. Public Sub AddPlayer(ByVal lPlayerID As Long, ByVal sName As String)
  296.     Dim lItem As ListItem
  297.   
  298.     Set lItem = lvMembers.ListItems.Add(, "K" & CStr(lPlayerID), sName)
  299.     lItem.SubItems(1) = "Silent"
  300.     lItem.SubItems(2) = cboMyGroup.List(0)
  301.     lItem.SubItems(3) = cboTalkingGroup.List(0)
  302.     
  303. End Sub
  304.  
  305. Public Sub RemovePlayer(ByVal lPlayerID As Long)
  306.     Dim lCount As Long
  307.     For lCount = lvMembers.ListItems.Count To 1 Step -1
  308.         If lvMembers.ListItems.Item(lCount).Key = "K" & CStr(lPlayerID) Then
  309.             'Remove this one
  310.             lvMembers.ListItems.Remove lCount
  311.         End If
  312.     Next
  313. End Sub
  314.  
  315. Private Sub Form_Unload(Cancel As Integer)
  316.     Me.Hide
  317.     DPlayEventsForm.DoSleep 50
  318.     Cleanup
  319. End Sub
  320.  
  321. Public Sub UpdateTarget(ByVal lPlayerID As Long, ByVal lIndex As Long)
  322.     Dim lCount As Long
  323.     For lCount = lvMembers.ListItems.Count To 1 Step -1
  324.         If lvMembers.ListItems.Item(lCount).Key = "K" & CStr(lPlayerID) Then
  325.             'Change my group
  326.             lvMembers.ListItems.Item(lCount).SubItems(3) = cboTalkingGroup.List(lIndex)
  327.         End If
  328.     Next
  329. End Sub
  330.  
  331. Public Sub UpdateGroup(ByVal lPlayerID As Long, ByVal lIndex As Long)
  332.     Dim lCount As Long
  333.     For lCount = lvMembers.ListItems.Count To 1 Step -1
  334.         If lvMembers.ListItems.Item(lCount).Key = "K" & CStr(lPlayerID) Then
  335.             'Change my group
  336.             lvMembers.ListItems.Item(lCount).SubItems(2) = cboMyGroup.List(lIndex)
  337.         End If
  338.     Next
  339. End Sub
  340.  
  341. Private Function AmIInList(ByVal lPlayerID As Long) As Boolean
  342.     Dim lCount As Long, fInThis As Boolean
  343.     
  344.     For lCount = lvMembers.ListItems.Count To 1 Step -1
  345.         If lvMembers.ListItems.Item(lCount).Key = "K" & CStr(lPlayerID) Then
  346.             fInThis = True
  347.         End If
  348.     Next
  349.     AmIInList = fInThis
  350. End Function
  351.  
  352. Private Sub UpdatePlayerList()
  353.  
  354.     'Get everyone who is currently in the session and add them if we don't have them currently.
  355.     Dim lCount As Long
  356.     Dim Player As DPN_PLAYER_INFO
  357.     
  358.     ' Enumerate players
  359.     For lCount = 1 To dpp.GetCountPlayersAndGroups(DPNENUM_PLAYERS)
  360.         If Not (AmIInList(dpp.GetPlayerOrGroup(lCount))) Then 'Add this player
  361.             Dim lItem As ListItem, sName As String
  362.             Player = dpp.GetPeerInfo(dpp.GetPlayerOrGroup(lCount))
  363.             sName = Player.Name
  364.             If sName = vbNullString Then sName = "Unknown"
  365.             If (Player.lPlayerFlags And DPNPLAYER_LOCAL = DPNPLAYER_LOCAL) Then glMyPlayerID = dpp.GetPlayerOrGroup(lCount)
  366.             Set lItem = lvMembers.ListItems.Add(, "K" & CStr(dpp.GetPlayerOrGroup(lCount)), sName)
  367.             lItem.SubItems(1) = "Silent"
  368.             lItem.SubItems(2) = cboMyGroup.List(0)
  369.             lItem.SubItems(3) = cboTalkingGroup.List(0)
  370.         End If
  371.     Next lCount
  372. End Sub
  373.  
  374. Private Function GetGroupID(ByVal lIndex As Long) As Long
  375.     Dim lCount As Long
  376.     Dim dpGroup As DPN_GROUP_INFO
  377.     
  378.     For lCount = 1 To dpp.GetCountPlayersAndGroups(DPNENUM_GROUPS)
  379.         dpGroup = dpp.GetGroupInfo(dpp.GetPlayerOrGroup(lCount))
  380.         If dpGroup.Name = "Group" & CStr(lIndex) Then
  381.             GetGroupID = dpp.GetPlayerOrGroup(lCount)
  382.         End If
  383.     Next lCount
  384. End Function
  385.  
  386. Private Sub DirectPlay8Event_AddRemovePlayerGroup(ByVal lMsgID As Long, ByVal lPlayerID As Long, ByVal lGroupID As Long, fRejectMsg As Boolean)
  387.     'VB requires that we must implement *every* member of this interface
  388. End Sub
  389.  
  390. Private Sub DirectPlay8Event_AppDesc(fRejectMsg As Boolean)
  391.     'VB requires that we must implement *every* member of this interface
  392. End Sub
  393.  
  394. Private Sub DirectPlay8Event_AsyncOpComplete(dpnotify As DxVBLibA.DPNMSG_ASYNC_OP_COMPLETE, fRejectMsg As Boolean)
  395.     'VB requires that we must implement *every* member of this interface
  396. End Sub
  397.  
  398. Private Sub DirectPlay8Event_ConnectComplete(dpnotify As DxVBLibA.DPNMSG_CONNECT_COMPLETE, fRejectMsg As Boolean)
  399.     If dpnotify.hResultCode <> 0 Then
  400.         'For some reason we could not connect.  All available slots must be closed.
  401.         MsgBox "Connect Failed.  Error: 0x" & CStr(Hex$(dpnotify.hResultCode)) & "  - This sample will now close.", vbOKOnly Or vbCritical, "Closing"
  402.         DPlayEventsForm.CloseForm Me
  403.     End If
  404. End Sub
  405.  
  406. Private Sub DirectPlay8Event_CreateGroup(ByVal lGroupID As Long, ByVal lOwnerID As Long, fRejectMsg As Boolean)
  407.     Dim lGroupNum As Long
  408.     Dim dpGroup As DPN_GROUP_INFO
  409.     
  410.     dpGroup = dpp.GetGroupInfo(lGroupID)
  411.     lGroupNum = CLng(Right$(dpGroup.Name, 1))
  412.     glGroupID(lGroupNum) = lGroupID
  413. End Sub
  414.  
  415. Private Sub DirectPlay8Event_CreatePlayer(ByVal lPlayerID As Long, fRejectMsg As Boolean)
  416.     Dim dpPeer As DPN_PLAYER_INFO
  417.     
  418.     dpPeer = dpp.GetPeerInfo(lPlayerID)
  419.     AddPlayer lPlayerID, dpPeer.Name
  420.     If (dpPeer.lPlayerFlags And DPNPLAYER_LOCAL) = DPNPLAYER_LOCAL Then
  421.         glMyPlayerID = lPlayerID
  422.     End If
  423. End Sub
  424.  
  425. Private Sub DirectPlay8Event_DestroyGroup(ByVal lGroupID As Long, ByVal lReason As Long, fRejectMsg As Boolean)
  426.     'VB requires that we must implement *every* member of this interface
  427. End Sub
  428.  
  429. Private Sub DirectPlay8Event_DestroyPlayer(ByVal lPlayerID As Long, ByVal lReason As Long, fRejectMsg As Boolean)
  430.     RemovePlayer lPlayerID
  431.     If lPlayerID = glMyPlayerID Then
  432.         glMyPlayerID = 0
  433.     End If
  434. End Sub
  435.  
  436. Private Sub DirectPlay8Event_EnumHostsQuery(dpnotify As DxVBLibA.DPNMSG_ENUM_HOSTS_QUERY, fRejectMsg As Boolean)
  437.     'VB requires that we must implement *every* member of this interface
  438. End Sub
  439.  
  440. Private Sub DirectPlay8Event_EnumHostsResponse(dpnotify As DxVBLibA.DPNMSG_ENUM_HOSTS_RESPONSE, fRejectMsg As Boolean)
  441.     'VB requires that we must implement *every* member of this interface
  442. End Sub
  443.  
  444. Private Sub DirectPlay8Event_HostMigrate(ByVal lNewHostID As Long, fRejectMsg As Boolean)
  445.     If lNewHostID = glMyPlayerID Then
  446.         frmVoice.Caption = frmVoice.Caption & " (HOST)"
  447.     End If
  448. End Sub
  449.  
  450. Private Sub DirectPlay8Event_IndicateConnect(dpnotify As DxVBLibA.DPNMSG_INDICATE_CONNECT, fRejectMsg As Boolean)
  451.     'VB requires that we must implement *every* member of this interface
  452. End Sub
  453.  
  454. Private Sub DirectPlay8Event_IndicatedConnectAborted(fRejectMsg As Boolean)
  455.     'VB requires that we must implement *every* member of this interface
  456. End Sub
  457.  
  458. Private Sub DirectPlay8Event_InfoNotify(ByVal lMsgID As Long, ByVal lNotifyID As Long, fRejectMsg As Boolean)
  459.     'VB requires that we must implement *every* member of this interface
  460. End Sub
  461.  
  462. Private Sub DirectPlay8Event_Receive(dpnotify As DxVBLibA.DPNMSG_RECEIVE, fRejectMsg As Boolean)
  463.     Dim lCount As Long, lOffset As Long
  464.     Dim lMsg As Long
  465.     Dim lIndex As Long
  466.     
  467.     'Here we will go through the messages
  468.     'The first item in our byte array is the MSGID we passed in
  469.     With dpnotify
  470.     GetDataFromBuffer .ReceivedData, lMsg, LenB(lMsg), lOffset
  471.     Select Case lMsg
  472.     Case MSG_CHANGEGROUP
  473.         GetDataFromBuffer .ReceivedData, lIndex, LenB(lIndex), lOffset
  474.         frmVoice.UpdateGroup dpnotify.idSender, lIndex
  475.     Case MSG_CHANGETALK
  476.         GetDataFromBuffer .ReceivedData, lIndex, LenB(lIndex), lOffset
  477.         frmVoice.UpdateTarget dpnotify.idSender, lIndex
  478.     Case MSG_SERVERCHANGEGROUP
  479.         If DPlayEventsForm.IsHost Then
  480.             RemovePlayerFromAllGroups dpnotify.idSender
  481.             GetDataFromBuffer .ReceivedData, lIndex, LenB(lIndex), lOffset
  482.             If lIndex > 0 Then dpp.AddPlayerToGroup glGroupID(lIndex), dpnotify.idSender, 0
  483.             frmVoice.UpdateGroup dpnotify.idSender, lIndex
  484.         End If
  485.     End Select
  486.     End With
  487. End Sub
  488.  
  489. Private Sub DirectPlay8Event_SendComplete(dpnotify As DxVBLibA.DPNMSG_SEND_COMPLETE, fRejectMsg As Boolean)
  490.     'VB requires that we must implement *every* member of this interface
  491. End Sub
  492.  
  493. Private Sub DirectPlay8Event_TerminateSession(dpnotify As DxVBLibA.DPNMSG_TERMINATE_SESSION, fRejectMsg As Boolean)
  494.     'VB requires that we must implement *every* member of this interface
  495. End Sub
  496.  
  497. Private Sub DirectPlayVoiceEvent8_ConnectResult(ByVal ResultCode As Long)
  498.     If ResultCode <> 0 Then
  499.         'For some reason we could not connect.  All available slots must be closed.
  500.         MsgBox "Connect Failed.  Error: 0x" & CStr(Hex$(ResultCode)) & "  - This sample will now close.", vbOKOnly Or vbCritical, "Closing"
  501.         DPlayEventsForm.CloseForm Me
  502.     End If
  503. End Sub
  504.  
  505. Private Sub DirectPlayVoiceEvent8_CreateVoicePlayer(ByVal playerID As Long, ByVal flags As Long)
  506.     'Someone joined, update the player list
  507.     UpdatePlayerList
  508. End Sub
  509.  
  510. Private Sub DirectPlayVoiceEvent8_DeleteVoicePlayer(ByVal playerID As Long)
  511.     'Someone quit, remove them from the session
  512.     RemovePlayer playerID
  513. End Sub
  514.  
  515. Private Sub DirectPlayVoiceEvent8_DisconnectResult(ByVal ResultCode As Long)
  516.     'VB requires that we must implement *every* member of this interface
  517. End Sub
  518.  
  519. Private Sub DirectPlayVoiceEvent8_HostMigrated(ByVal NewHostID As Long, ByVal NewServer As DxVBLibA.DirectPlayVoiceServer8)
  520.     'VB requires that we must implement *every* member of this interface
  521. End Sub
  522.  
  523. Private Sub DirectPlayVoiceEvent8_InputLevel(ByVal PeakLevel As Long, ByVal RecordVolume As Long)
  524.     'VB requires that we must implement *every* member of this interface
  525. End Sub
  526.  
  527. Private Sub DirectPlayVoiceEvent8_OutputLevel(ByVal PeakLevel As Long, ByVal OutputVolume As Long)
  528.     'VB requires that we must implement *every* member of this interface
  529. End Sub
  530.  
  531. Private Sub DirectPlayVoiceEvent8_PlayerOutputLevel(ByVal playerID As Long, ByVal PeakLevel As Long)
  532.     'VB requires that we must implement *every* member of this interface
  533. End Sub
  534.  
  535. Private Sub DirectPlayVoiceEvent8_PlayerVoiceStart(ByVal playerID As Long)
  536.     'Someone is talking, update the list
  537.     UpdateList playerID, True
  538. End Sub
  539.  
  540. Private Sub DirectPlayVoiceEvent8_PlayerVoiceStop(ByVal playerID As Long)
  541.     'Someone stopped talking, update the list
  542.     UpdateList playerID, False
  543. End Sub
  544.  
  545. Private Sub DirectPlayVoiceEvent8_RecordStart(ByVal PeakVolume As Long)
  546.     'I am talking, update the list
  547.     UpdateList glMyPlayerID, True
  548. End Sub
  549.  
  550. Private Sub DirectPlayVoiceEvent8_RecordStop(ByVal PeakVolume As Long)
  551.     'I have quit talking, update the list
  552.     UpdateList glMyPlayerID, False
  553. End Sub
  554.  
  555. Private Sub DirectPlayVoiceEvent8_SessionLost(ByVal ResultCode As Long)
  556.     'The voice session has exited, let's quit
  557.     MsgBox "The DirectPlayVoice session was lost.  This sample is exiting.", vbOKOnly Or vbInformation, "Session lost."
  558.     DPlayEventsForm.CloseForm Me
  559. End Sub
  560.  
  561.  
  562.